<template>
	<view>
		<view class="cu-list menu-avatar" >
			<view class="cu-item" style="height: 60px;" v-for="(item,index) in listData" :key="index">
				<view class=" guoshao-qianbao-view" >
					<image src="../static/qianbao.png" class="guoshao-image" mode="aspectFit"></image>
				</view>
				<view class="content">
					<view class="">
						<view class="text-cut " v-if="item.dataType == 1">钱包收入</view>
						<view class="text-cut" v-if="item.dataType == 2">钱包支出</view>
					</view>
					<view class="text-gray text-sm flex">
						<view class="text-cut">{{ item.createTime }}</view>
					</view>
				</view>
				<view class="action">
					<view class="cu-tag round bg-green sm" v-if="item.dataType == 1">
						<text>+ {{item.money}}</text>
					</view>
					<view class="cu-tag round bg-red sm" v-if="item.dataType == 2">
						<text>- {{item.money}}</text>
					</view>
				</view>
			</view>
			<!--加载loadding-->
			<tui-loadmore :visible="loadding"></tui-loadmore>
			<tui-nomore :visible="!pullUpOnLast" bgcolor="#ffffff"></tui-nomore>
			<!--加载loadding-->
		</view>
	</view>
</template>

<script>
import tuiLoading from '../../components/loading/loading';
import tuiLoadmore from '../../components/loadmore/loadmore';
import tuiNomore from '../../components/nomore/nomore';

const http = require('../../utils/http.js');

export default {
    components: {
        tuiLoading,
        tuiLoadmore,
        tuiNomore
    },
    data() {
        return {
            loadding: false,
            listData: [],
            pullUpOnLast: true,
        };
    },
    onLoad: function (options) {
		this.list(true);
    },
    onPullDownRefresh: function () {
		uni.showNavigationBarLoading()
		let that = this;
		setTimeout(function(){
			that.list(true);
			uni.hideNavigationBarLoading(); //完成停止加载图标
			uni.stopPullDownRefresh();
		},1000);
	},
    onReachBottom: function () {
        if (!this.pullUpOnLast) {
            return;
        }
		this.list(false);
    },
    methods: {
		
        list: function (refresh) {
            let that = this;
            that.setData({
                loadding: true
            });
            let offset = 0;

            if (!refresh) {
                offset = that.listData.length;
            }
			uni.showLoading({
				title:'加载中'
			})
            var params = {
				baseUrl:true,
                url: '/u/walletDetails/selectWalletDetails',
                method: 'GET',
                data: {
                    offset: offset
                },
                callBack: function (res) {
					if(res.code == 200){
						that.setData({
						    loadding: false,
						    listData: refresh ? res.data.list : that.listData.concat(res.data.list),
						    pullUpOnLast: !res.data.isLastPage ? true : false
						});
					}else{
						that.setData({
						    loadding: false,
							pullUpOnLast:false
						});
					}
					uni.hideLoading()
                }
            };
            http.request(params);
        },
    }
};
</script>


<style>
@import './walletDetails.css';
</style>
